package main

import "fmt"

func main() {
	for i := 1; i < 20; i++ {
		fmt.Printf("i = %d, steps = %d\n", i, climbStairs(i))
	}

	for i := 1; i < 20; i++ {
		fmt.Printf("i = %d, steps = %d\n", i, climbStairs2(i))
	}
}

// dp[i] = dp[i-1] + dp[i-2]
func climbStairs(n int) int {
	dp := make([]int, n+1)
	dp[0], dp[1] = 1, 2
	for i := 2; i < n; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}
	return dp[n-1]
}

func climbStairs2(n int) int {
	if n == 1 {
		return 1
	}
	first, second := 1, 2
	for i := 3; i <= n; i++ {
		first, second = second, first+second
	}
	return second
}
